<template>
  <div class="container">
    <strong>编辑：</strong>
    <div class="list">
      <CheckEditor
        v-for="item in productsRef"
        v-model:model-value="item.sell"
        v-model:title="item.title"
        :key="item.id"
      />
    </div>
    <div class="list">
      <strong>销售中:</strong>
      <div>
        <template v-for="(item, index) in sellsRef" :key="item.id">
          <span>{{ index + 1 }}</span>
          <strong>{{ item.title }}</strong>
        </template>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
import CheckEditor from "./components/CheckEditor.vue";

const productsRef = ref([
  {
    id: 1,
    sell: true,
    title: "iphone12",
  },
  { id: 2, sell: false, title: "xiaomi" },
  { id: 3, sell: true, title: "huawei" },
  { id: 4, sell: true, title: "vivo" },
]);

const sellsRef = computed(() => productsRef.value.filter((v) => v.sell));
</script>

<style scoped>
.container {
  margin-top: 50px;
  width: 880px;
  margin: 50px auto;
}
.list {
  display: flex;
  margin: 1em 0;
  align-items: center;
}
strong {
  margin-right: 1em;
}
</style>
